package com.shenzhenai.composebasic.components

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.RangeSlider
import androidx.compose.material3.Slider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.tooling.preview.Preview

/**
 * @author huangzehui
 * @date 12/9/2025 下午10:47 周五
 * @description
 *
 *
 * Slide 案例
 * https://www.bilibili.com/video/BV12T4y1D7ST?vd_source=e07cc8cc94eb22bd76722071b03cd199&spm_id_from=333.788.player.switch
 */


@Composable
fun SliderSample() {
    Column {

        var value by remember {
            mutableStateOf(0f)
        }
        // 滑块的使用
        Slider(
            value = value, onValueChange = {
                value = it
            },
            // 设置值的区间
            valueRange = 0f..100f,
            // 设置每次滑动的步长(就是将整个进度条加入 steps+2 个顶点，拖动后松开，只会在最近的定点停留)
            steps = 1
        )


        var value1 by remember {
            mutableStateOf(5f..10f)
        }

        // 区间滑块
        RangeSlider(
            // 拖动后的滑块区间
            value = value1,
            // 滑块的可滑动区间
            valueRange = 5f..10f,
            // 滑块滑动后的区间回调
            onValueChange = {
                value1 = it
            })


    }


}

@Preview
@Composable
fun SliderSampleSample() {
    SliderSample()
}